<?php

class Style extends ObjLib\Object {
	var $params = array (
		'title',
		'header',
		'footer'
	);
	
	function Style ($id = false, $title = false) {
		$this->id = $id;
		$this->title = $title;
		
		if ($this->id !== false) {
			$this->load ();
		}
		else if ($this->title != false) {
			$this->load ('title');
		}
	}	
	
	function createTable () {
		global $dbh;
  
  		$tableName = get_class ($this);
		
		$query = <<<QUERY
CREATE TABLE `{$tableName}` (
  `id` int(10) char(32) not null,
  `title` varchar(255) NOT NULL,
  `header` TEXT NOT NULL,
  `footer` TEXT NOT NULL,  
  PRIMARY KEY  (`id`),
  KEY `title_index` (`title`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
QUERY;

		$dbh->exec ($query);
		return true;
	}
	
	function fillNextPosition ($content) {
		$this->content = str_replace('<?php /*TMPL_POS*/ ?>', $content, $this->content);
	}
	
	function &getHeader() {
		return $this->header; 
	}
	
	function &getFooter() {
		return $this->footer; 
	}
}

?>